MyGame.s4 = function(game) {
	
	

};


MyGame.s4.prototype = {
    create: function() {
    	
    	
		console.log('s4-倒计时')

        game.add.image(0,0,'s2_s3_bg');

        game.s4_text_1 = game.add.image(game.world.centerX,game.world.centerY - 80,'s4_text_1');
        game.s4_text_1.anchor.set(0.5,0.5);

        
        game.s4_text_2 = game.add.image(game.world.centerX,game.world.centerY,'s4_text_2');
        game.s4_text_2.anchor.set(0.5,0.5);

        
        game.s4_text_3 = game.add.image(game.world.centerX,game.world.centerY + 80,'s4_text_3');
        game.s4_text_3.anchor.set(0.5,0.5);
 
        

        game.s4_time_1 = game.add.image(game.world.centerX,game.world.centerY,'s4_timer_1');
        game.s4_time_1.anchor.set(0.5,0.5);
        game.s4_time_1.alpha=0;

        game.s4_time_2 = game.add.image(game.world.centerX,game.world.centerY,'s4_timer_2');
        game.s4_time_2.anchor.set(0.5,0.5);
        game.s4_time_2.alpha=0;

        game.s4_time_3 = game.add.image(game.world.centerX,game.world.centerY,'s4_timer_3');
        game.s4_time_3.anchor.set(0.5,0.5);
        game.s4_time_3.alpha=0;


        //.onComplete.add(this.s4_text_fadeOut,this)

        // 2s内alpha变为1，自动开始，延时0s，重复1000次，yoyo //Phaser.Easing.Cubic.Out Phaser.Easing.Linear.None
        game.add.tween(game.s4_text_1).from( { alpha: 0 ,y:'-10'}, 800, Phaser.Easing.Cubic.Out, true, 1000)
        game.add.tween(game.s4_text_2).from( { alpha: 0 ,y:'-10'}, 800, Phaser.Easing.Cubic.Out, true, 1200)
        game.add.tween(game.s4_text_3).from( { alpha: 0 ,y:'-10'}, 800, Phaser.Easing.Cubic.Out, true, 1400).onComplete.add(this.s4_text_fadeOut,this)

        


        GameUI.cutscenes()
        

       

    },

    s4_text_fadeOut:function(){
        game.add.tween(game.s4_text_1).to( { alpha: 0,y:'-10' }, 800, Phaser.Easing.Cubic.Out, true, 1000)
        game.add.tween(game.s4_text_2).to( { alpha: 0,y:'-10' }, 800, Phaser.Easing.Cubic.Out, true, 1200)
        game.add.tween(game.s4_text_3).to( { alpha: 0,y:'-10' }, 800, Phaser.Easing.Cubic.Out, true, 1400).onComplete.add(this.countDown_3,this)
    },

    countDown_3:function(){

        game.add.tween(game.s4_time_3.scale).from( {x:3,y:3 }, 500, Phaser.Easing.Cubic.Out, true, 0);
        game.add.tween(game.s4_time_3).to( {alpha:1}, 500, Phaser.Easing.Cubic.Out, true, 0).onComplete.add(function(){
            game.add.tween(game.s4_time_3).to( {alpha:0}, 500, Phaser.Easing.Cubic.Out, true, 0).onComplete.add(this.countDown_2,this)
            game.add.tween(game.s4_time_3.scale).to( {x:0.3,y:0.3}, 500, Phaser.Easing.Cubic.Out, true, 0)
        },this)

    },

    countDown_2:function(){

        game.add.tween(game.s4_time_2.scale).from( {x:3,y:3 }, 500, Phaser.Easing.Cubic.Out, true, 0);
        game.add.tween(game.s4_time_2).to( {alpha:1}, 500, Phaser.Easing.Cubic.Out, true, 0).onComplete.add(function(){
            game.add.tween(game.s4_time_2).to( {alpha:0}, 500, Phaser.Easing.Cubic.Out, true, 0).onComplete.add(this.countDown_1,this)
            game.add.tween(game.s4_time_2.scale).to( {x:0.3,y:0.3}, 500, Phaser.Easing.Cubic.Out, true, 0)
        },this)

    },

    countDown_1:function(){

        game.add.tween(game.s4_time_1.scale).from( {x:3,y:3 }, 500, Phaser.Easing.Cubic.Out, true, 0);
        game.add.tween(game.s4_time_1).to( {alpha:1}, 500, Phaser.Easing.Cubic.Out, true, 0).onComplete.add(function(){
            game.add.tween(game.s4_time_1).to( {alpha:0}, 500, Phaser.Easing.Cubic.Out, true, 0).onComplete.add(function(){
                game.state.start('s5')
            },this)
            game.add.tween(game.s4_time_1.scale).to( {x:0.3,y:0.3}, 500, Phaser.Easing.Cubic.Out, true, 0)
        },this)

    },

    update: function() {
    	
    	
    	
    },
    
    
    
    render : function(){
    	/*game.obstacles.forEach(function(item){
            game.debug.body(item);
        })
    	game.debug.body(game.player);*/
    }
};

